package com.yuxi.Config;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.yuxi.Dao.InformationSortDao;
import com.yuxi.Dao.UserInfoDao;
import com.yuxi.Entity.UserInfo;
import com.yuxi.spring.jbpm.Util.SpringContextUtils;

public class UserTableStatic {
	private static  List<UserInfo> userList=new ArrayList<UserInfo>();
	
	
	public static List<UserInfo> getUserList() {
		return userList;
	}


	public static void setUserList(List<UserInfo> userList) {
		UserTableStatic.userList = userList;
	}


	public static void getAllByDb(){
		UserInfoDao i=(UserInfoDao) SpringContextUtils.getBeanByClass(UserInfoDao.class); 		
		setUserList(i.getALl());
	}
	
	public static UserInfo findUserById(Integer id){
		for (Iterator iterator = userList.iterator(); iterator.hasNext();) {
			UserInfo userInfo = (UserInfo) iterator.next();
			if(userInfo.getUserId()==id){
				return userInfo;
			}			
		}
		UserInfoDao i=(UserInfoDao) SpringContextUtils.getBeanByClass(UserInfoDao.class);	
		UserInfo u=i.getUser(id);
		userList.add(u);
		return u;		
	};
	
	
}
